package com.practice;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public final class TimerExecutor {
	public static void run() {
		Timer timer = new Timer();
		
		timer.schedule(new TimerTask() {
			
			@Override
			public void run() {
				System.out.print("1 second: ");
				System.out.println(new Date().toString());				
			}
		}, 0, 1 * 1000);
		
		timer.schedule(new TimerTask() {
			
			@Override
			public void run() {
				System.out.print("2 seconds: ");
				System.out.println(new Date().toString());
				
			}
		}, 0, 2 * 1000);
		
		timer.schedule(new TimerTask() {
			
			@Override
			public void run() {
				System.out.print("4 seconds: ");
				System.out.println(new Date().toString());
			}
		}, 0, 4 * 1000);
	}
}
